package com.gdwstudy.threadMethod;

import com.gdwstudy.polyParameter.Manager;

/**
 * @author 关道伟
 * @version 1.0
 */
public class ThreadMethod {
    public static void main(String[] args) {
        //测试相关的方法
        T t = new T();
        t.setName("关道伟");
        t.setPriority(Thread.MIN_PRIORITY);//将线程的优先级设置到最低
        t.start();//启动子线程

        //主线程打印
        for (int i = 0; i < 5; i++) {
            try {
                Thread.sleep(1000);
                System.out.println("hi"+i);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
        t.interrupt();
    }
}


class T extends Thread{
    @Override
    public void run() {
        for (int i = 0; i < 100; i++) {
            System.out.println(Thread.currentThread().getName()+" 吃包子.."+i);
        }
        try {
            System.out.println(Thread.currentThread().getName()+" 休眠中...");
            Thread.sleep(20000);
        } catch (InterruptedException e) {
            //当线程执行到一个interrupt方法时 就会catch一个异常 可以加入自己的业务代码
            //Interru...捕捉到中断异常
            System.out.println(Thread.currentThread().getName()+"中断...");
        }
    }
}